home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / Macintosh Programmer’s Workshop / MPW 3.1 / SADE 1.1 / SADEScripts / FCBChecker < prev    next >
Text File  |  1990-12-13  |  3KB  |  77 lines

  1. #    Symbolic Application Debugging Environment    1.0 Final
  2. #
  3. #    Copyright Apple Computer, Inc. 1987-1988
  4. #    All rights reserved.
  5.  
  6. ###############################################################################
  7. # a small set of routines to list out all of the FCBs
  8.  
  9. #-------------------------------------------------------------------------------------------
  10. #    FCBLen --     returns the length of the FCB, 20 if we are running MFS (which we won't ever be)
  11. #                or what's in $3F6 if HFS.
  12. #-------------------------------------------------------------------------------------------
  13. func FCBLen    ()
  14.  
  15. define FSFCBLen := ^word($3F6)^                    # fetch value of low-memory global
  16. define MFSFCBLen := 20                            # we know this to be true, for ever and ever
  17.  
  18.     if (FSFCBLen < 0)                             # less than zero means MFS
  19.         return(MFSFCBLen);
  20.     else
  21.         return(FSFCBLen);
  22.     end
  23. end    # func FCBLen
  24.  
  25.  
  26. #-------------------------------------------------------------------------------------------
  27. #    DisplayAnFCB -- displays the entryNumth entry in the FCB table.  Does NOT check to see
  28. #                    if the entry is actually in the table, that's left to the caller
  29. #-------------------------------------------------------------------------------------------
  30. proc DisplayAnFCB(entryNum)
  31.     
  32. define theFCBsAddr,theRefNum
  33. # the following are offsets into the FCB
  34. define fileNumOffset := 0;
  35. define PEOFOffset := 12;
  36. define fileTypeOffset := 50;
  37. define fileNameOffset := 62;
  38.  
  39.     theRefNum := (entryNum * FCBLen()) + 2;     # "+2" accounts for the length word at the
  40.                                                 # start of the FCB block
  41.     theFCBsAddr:= FCBsPtr^+ theRefNum;
  42.     
  43.     printf("$%.4X",theRefNum);                     # print the refnum
  44.     if (theFCBsAddr+fileNumOffset)^ = 0         # the file is unused
  45.         printf("     unused\n");
  46.     else
  47.         printf("     $%.8X",(theFCBsAddr+fileNumOffset)^);    # print the file number
  48.         printf("     $%.8X",(theFCBsAddr+PEOFOffset)^);
  49.         printf("     %#s",(theFCBsAddr+fileTypeOffset)^);
  50.         printf("     %P\n",^pstring(theFCBsAddr+fileNameOffset)^);
  51.     end
  52. END;  # proc DisplayAnFCB
  53.  
  54.  
  55. #-------------------------------------------------------------------------------------------
  56. #    DisplayFCBs -- loops through and lists all FCBs by calling DisplayAnFCB
  57. #-------------------------------------------------------------------------------------------
  58. proc DisplayFCBs
  59.  
  60. # global variable
  61. define global FCBsPtr  := $34E                    # location of pointer to FCBs
  62.  
  63. define i,numFCBs
  64.  
  65.     # print header
  66.     numFCBs:= ^Word(FCBsPtr^)^ / FCBLen();     # we don't really need this variable, but what the hey
  67.     printf("There are %t FCBs starting at $%.8X\n\n",numFCBs,FCBsPtr^);
  68.     printf("RefNum    File#         PEOF          FType    Name\n");
  69.     printf("------    -----         ----          -----    ----\n");
  70.     
  71.     for i:= 0 to numFCBs-1                        # FCB table is zero based
  72.         DisplayAnFCB(i)                          # display this FCB
  73.     end    #for
  74.     undefine FCBsPtr;
  75. end; # proc DisplayFCBs
  76.  
  77.